package com.easytopit.demo.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.easytopit.demo.domain.Hall;
import com.easytopit.demo.exception.BizException;
import com.easytopit.demo.service.HallService;

/**
 * @author YWQ
 *
 */
@Controller
public class HallController {

	@Autowired
	private HallService hallService;
	
	@RequestMapping("hallControllerAdd.do")
	public String add(@RequestParam("cinemaName") String cinemaName,@RequestParam("name") String name,
			@RequestParam("quantity") Integer quantity,@RequestParam("seat") String seat,
			HttpServletRequest request,HttpServletResponse response,ModelMap map) throws BizException{
		Hall add = hallService.add(cinemaName, name, quantity, seat);
		if (add != null) {
			map.put("message", "录入影厅成功");
		}
		return "";
	}
	
	public String update(@RequestParam("cinemaName") String cinemaName,@RequestParam("name") String name,
			@RequestParam("quantity") Integer quantity,@RequestParam("seat") String seat,
			HttpServletRequest request,HttpServletResponse response,ModelMap map) throws BizException{
		Integer update = hallService.update(cinemaName, name, quantity, seat);
		if (update != null) {
			map.put("message", "修改成功");
		}
		return "";
	}
}